#include <QDataStream>
#include "documentmessage.h"

DocumentMessage::DocumentMessage()
{
}

DocumentMessage::DocumentMessage(QByteArray bytes)
{
	QDataStream sin(bytes);

	//get the operation
	quint8 tmp;
	sin >> tmp;
	operation = tmp;

	sin >> tmp;
	type = (docType)tmp;

	sin >> docId >> creator >> tabN;
}

QByteArray DocumentMessage::toBytes()
{
	QByteArray bytes;
	QDataStream sout(&bytes, QIODevice::WriteOnly);

	sout << (quint8)Message::DOCUMENT << (quint8)type << docId << creator << tabN;

	return bytes;
}
